  import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class HandlingJavaPopups {

	public static void main(String[] args) {
//HANDLING JAVA ALERTS AND POPUPS//
		WebDriver driver = new FirefoxDriver();
		driver.get("http:www.goindigo.in");	

//USE XPATH TO CLICK ON THE RADIO BUTTON & WHEN YOU RUN IT, A POPUP WINDOW WILL APPEAR
	    //driver.findElement(By.xpath(".//*[@id='onewayradio']")).click();
	driver.findElement(By.xpath(".//*[@id='onewayradio']")).click();
	
//POP UP WINDOW IS NOT A PART OF FIREFOX SO WE HAVE TO SWITCH IT using switchTo() from dropdown selection    
//THEN PUT A DOT AFTER switchTo(). AND SELECT ALERT. THEN CREATE OBJECT CALL al
//ALSO CREATE TYPE WHICH IS ALWAYS AFTER:(colon) FROM THE DROPDOWN SELECTION ex-(.alert()=alert). 
//THEN TYPE Alert as variable type and Import package to remove red lines	    
	  	
	Alert al=driver.switchTo().alert();
	   
// THEN TO CLICK OK, YES ,ACCEPT OR ANY POSITIVE ANSWER, choose accept() from drop down
	// or choose dismiss to cancel
	   al.dismiss();	   
		

	}

}
